from django.db import models

# Create your models here.


class Podr(models.Model):
    podr_code = models.PositiveIntegerField()
    podr_name = models.CharField(max_length=120)

    def __str__(self) -> str:
        return f"{self.podr_code} - {self.podr_name}"


class Otd(models.Model):
    otd_code = models.PositiveIntegerField()
    otd_name = models.CharField(max_length=120)

    def __str__(self) -> str:
        return f"{self.otd_name}"


class Dolj(models.Model):
    dolj_code = models.PositiveIntegerField()
    dolj_name = models.CharField(max_length=120)

    def __str__(self) -> str:
        return f"{self.dolj_name}"


class Cert(models.Model):
    ncert = models.CharField(max_length=50)

    def __str__(self) -> str:
        return f"{self.ncert}"


class Worker(models.Model):
    id_worker = models.PositiveIntegerField(unique=True)
    fam_worker = models.CharField(max_length=35)
    im_worker = models.CharField(max_length=40)
    ot_worker = models.CharField(
        max_length=35,
        blank=True)
    dr = models.DateField()
    podr = models.ForeignKey(
        Podr,
        on_delete=models.CASCADE)
    otd = models.ForeignKey(
        Otd,
        on_delete=models.CASCADE)
    dlj = models.ForeignKey(
        Dolj,
        on_delete=models.CASCADE)
    cert = models.ForeignKey(
        Cert,
        on_delete=models.PROTECT)

    def __str__(self) -> str:
        return f"{self.id_worker} - {self.fam_worker} {self.im_worker} {self.ot_worker}"


# class S_ETAP_VACCINE(models.Model):


class Vaccine(models.Model):
    nvaccine = models.CharField(max_length=50)
    id_arena = models.PositiveIntegerField(unique=True)

    def __str__(self) -> str:
        return str(self.nvaccine)


# class S_SH_VACCINE(models.Model):
#         to=S_ETAP_VACCINE)


class Vaccine2(models.Model):
    vaccine = models.ForeignKey(Vaccine, on_delete=models.PROTECT)
    data_vaccine = models.DateField()
    etap_vaccine = models.ManyToManyField
    data_plan = models.DateField()
    rez_issl = models.CharField(max_length=200, blank=True)
    data_issl = models.DateField(blank=True)
    komment = models.CharField(max_length=5000, blank=True)

    def __str__(self) -> str:
        return f"{self.vaccine.__str__()}"


class Vaccine3(models.Model):
    id_worker = models.ForeignKey(Worker, on_delete=models.PROTECT)
    id_vaccine = models.ForeignKey(Vaccine2, on_delete=models.PROTECT)

    def __str__(self) -> str:
        return f"{self.id_worker} - {self.id_vaccine}"
